<template>
	<view>
		<!-- 头部标题 -->
		<view class="cu-bar bg-white">
			<view class="action sub-title">
				<text class="text-xl text-bold text-green">课堂详细</text>
				<text class="bg-green"></text>
				<!-- last-child选择器-->
			</view>
		</view>
		<!-- 头部标题 end -->


		<!-- 头部内容区域 -->

		<view class="bg-gradual-blue padding  text-center shadow-blur" style="width: 100vw;height: 300upx; display: flex;justify-content: center;align-items: center;">


			<view style="display: flex;flex-direction: column;justify-content: center;align-items: center;">
				<text style="font-size: 40upx;">第{{myself.index}}名</text>
				<text style="margin-top: 20upx;">当前积分{{myself.name}}</text>
			</view>

		</view>

		<!-- end -->

		<!-- 定位 导航栏 -->
		<view class="padding radius text-center shadow-blur bg-cyan" style="display: flex;width: 90vw;margin-left: 5vw;height: 200upx;position: absolute;top: 310upx;align-items: center;justify-content:space-around;">


			<view @click.native="toPageDesc(0)" style="display: flex;justify-content: center;align-items: center;flex-direction: column;">
				<image style="height: 100upx;width: 100upx;border-radius: 100%;" src="../../static/logo.png"></image>
				<text style="margin-top: 15upx;">参与签到</text>
			</view>

			<view @click.native="toPageDesc(1)" style="display: flex;justify-content: center;align-items: center;flex-direction: column;">
				<image style="height: 100upx;width: 100upx;border-radius: 100%;" src="../../static/logo.png"></image>
				<text style="margin-top: 15upx;">上传作业</text>
			</view>

			<view @click.native="toPageDesc(2)" style="display: flex;justify-content: center;align-items: center;flex-direction: column;">
				<image style="height: 100upx;width: 100upx;border-radius: 100%;" src="../../static/logo.png"></image>
				<text style="margin-top: 15upx;">抢答</text>
			</view>

		</view>
		<!-- end -->



		<!-- 人数 -->
		<view class="" style="display: flex;justify-content: space-between;margin-top: 100upx;padding: 30upx;">
			<text style="font-weight: 600;">成员总数</text>
			<text>{{listData.length}}人</text>
		</view>
		<!-- end -->


		<view class="" style="margin-left: 5vw; width: 90vw;height: 1upx;background: #AAAAAA;"></view>

		<!-- 列表 -->
		<view class="shadow-blur shadow-warp" v-for="(item,index) in listData" :key="index" @click.native="toPageDesc(3,index)">

			<view class="bg-white" style="padding: 20upx; width: 100vw;height: 150upx;margin-top: 10upx;display: flex;align-items: center;">

				<text style="color: red;">1</text>

				<image style="width: 100upx;height: 100upx;margin-left: 10upx;" src="../../../static/logo.png"></image>

				<view style="display: flex;flex-direction: column;margin-left: 20upx;width: 50vw;">
					<text>{{item.studentName}}</text>
					<text style="margin-top: 15upx;">{{item.idcard}}</text>
				</view>

				<view class="" style="display: flex;align-content: center;justify-content: center;">
					<text style="margin-right: 20upx;margin-top: -5upx;"><text style="color: red;margin-right: 10upx;">{{item.score}}</text>分数</text>
					<text class="lg text-gray cuIcon-right"></text>
				</view>
			</view>
			<!-- <view class="" style="margin-left: 5vw; width: 90vw;height: 1upx;background: #AAAAAA;margin-top: 10upx;"></view> -->

		</view>
		<!-- end -->


	</view>
</template>

<script>
	export default {
		data() {
			return {
				classId: null,
				listData: [],
				currentIndex: 0,
				myself: {
					name: "",
					index: 0,
					score: 0
				}
			}
		},
		onLoad(options) {
			this.myself.name = uni.getStorageSync('user_info').userName
			console.log(this.myself.name)

			this.classId = options.id

			uni.setStorageSync('clazzId', this.classId)
		},
		onShow() {
			this.getClassDescData()
		},
		methods: {

			// 获取列表数据
			getClassDescData: function(id) {
				var _this = this
				uni.request({
					url: _this.api + "join/getMember",
					method: "POST",
					header: {
						"content-type": "application/x-www-form-urlencoded"
					},
					data: {
						clazzId: this.classId
					},
					success: (res) => {
						_this.listData = res.data.data;
						_this.listData.forEach(function(e, index) {
							if (e.studentName == _this.myself.name) {
								_this.myself.index = index + 1
								_this.myself.scroe = e.score
							}
						})
					},
					fail: (err) => {
						uni.showToast({
							title: "查询数据失败！请稍后在试~~",
							icon: "none",
							duration: 1000
						})
					}
				})
			},

		
		
			// 答题数据
			getAnswerData() {
				uni.showLoading({
					title: "数据加载中..."
				})
				uni.request({
					url: _this.api + "answer/studentHistory",
					data: {
						uid: _this.studentId,
					},
					header: {
						"content-type": "application/x-www-form-urlencoded"
					},
					method: "POST",
					success: (res) => {
						uni.hideLoading();
						_this.AnswerData = res.data.data;
					},
					fail: (err) => {
						uni.hideLoading();
						uni.showToast({
							title: "答题数据获取失败！请稍后在试~~",
							duration: 1000,
							icon: "none"
						})
					}

				})
			},


			toPageDesc: function(index) {
				if (index == 0) { //跳转签到详细页面
					uni.navigateTo({
						url: '/pages/sign/sign',
					});
				} else if (index == 1) {
					uni.navigateTo({
						url: '/pages/worklist/worklist',
					});
				} else if (index == 2) {
					uni.navigateTo({
						url: '/pages/answer/answer',
					});
				}
			}
		}
	}
</script>

<style>

</style>
